Skip to main content

clickChunk

Type

function

Summary

Returns the position of the word or grouped text that the user last clicked.

Syntax

the clickChunk
clickChunk()

Description

Use the clickChunk function within a mouseDown, mouseUp, or selectionChanged handler to determine which word or text group the user clicked, in order to provide hypertext (clickable text) or take some action based on the click.

The clickChunk function is cleared at the next mouse click, as well as after some editing actions such as deleting text. If the last click was not in a field, the clickChunk function returns empty.

The returned value reports the word the user clicked: the startChar is the first character of the word, and the endChar is the last character. If the textStyle of the clicked text is "link", the returned value specifies the entire grouped text|text group.

Important

Words are defined a little differently by the clickChunk function than the way they are used in chunk expressions. A word, for purposes of the clickChunk, is any text delimited by spaces, tabs, returns, or punctuation. If you click a punctuation character, only that character is returned. This means that, for example, clicking a hyphenated word only returns the part of the word that was clicked.

The returned value indicates the text that the mouse pointer was over when the mouse was clicked. Moving the mouse before the mouse button is released does not affect the value returned by the clickChunk.

If the field is locked, the clickChunk function is most useful within a handler (such as mouseDown or mouseUp) that is triggered by the mouse click.

If the field is unlocked, mouseDown and mouseUp messages are not sent when the user clicks in the field (unless the user right-clicks or holds down the Control key while clicking). Use the clickChunk function within a selectionChanged handler to determine what characters the user is editing in an unlocked field.

To get the text of the word or text group clicked, use the clickText function.

Examples

the clickChunk
select the clickChunk

keyword: character, characters, word, field

message: mouseDown, mouseUp, selectionChanged

property: textStyle

control structure: function

function: clickText, selectedChunk, dropChunk, clickStack, clickChar

glossary: return, chunk expression, handler, return value, trigger, message, unlock, grouped text, hypertext

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

mobile

Thank you for your feedback!

Was this page helpful?